import {guid} from '@/utils/CommonUtils';

let DefaultFormDefinition = {
  id: undefined,
  formName: 'form_' + guid(),
  showName: "单据名称",
  tableName: undefined,
  width: 900,
  fields: [],
  views: [{
    id: guid(),
    viewName: '主视图',
    viewDefinition: '',
    viewDesignDefinition: '',
    main: '1',
    formId: undefined,
    width: 900,
    viewKey: guid(),
  }],
  processForm: false,
  subForms: [],
  flows: [],
  menus: [],
  appMenus: [],
  viewActions: []
};

let DefaultViewAction = {
  id: undefined,
  viewId: undefined,
  sort: undefined,
  actionKey: undefined,
  actionName: undefined,
  main: '1', // 是否是主视图(0 不是, 1是)
  systemPreset: '0', // 是否是系统预制(0 不是, 1是)
  actionType: undefined, // 操作类型 //edit, approve, show
  fieldActions: [],
  subFormButtonAction: []
};

let DefaultSubFormButtonAction = {
  id: undefined,
  subFormId: undefined,
  viewActionId: undefined,
  defaultAddButtonAuth: '1',
  defaultRemoveButtonAuth: '1',
  defaultMinLines: 0,
};

let DefaultFieldAction = {
  id: undefined,
  defaultValue: undefined,
  defaultValueAuto: '0', //是否自动(0 手动, 1系统变量)
  defaultAuth: undefined, //默认权限(browse, hide, edit)
  defaultNotNull: '0', //默认是否必填(0 不必填, 1必填)
  formName: undefined,
  formField: undefined,
  fieldShowName: undefined,
  sort: undefined,
  fieldComponent: undefined,
  defaultValueText: undefined,
  actionFormulas: []
};

let FieldVo = {
  formShowName: undefined, //单据显示名称
  formName: undefined,     // 单据名称
  formField: undefined,     // 字段数据库名称
  formFieldVariable: undefined, // 字段变量名称
  formFieldVariableShowName: undefined, //字段变量显示名称
  main: false, //是否是主表字段
  fieldShowName: undefined, //字段在单据中的名称
  fieldComponent: undefined, //字段的组件
};

let DefaultActionFormula = {
  id: undefined,
  viewActionId: undefined,
  formulaId: undefined,

  auth: undefined,
  notNull: undefined,
  sort: undefined,
  formula: {
    id: undefined,
    formulaText: undefined,
    formulaTitle: undefined,
    formulaRefs: null,
  }
};

let DefaultSubFormDefinition = {
  id: undefined,
  formName: 'formson_' + guid(),
  showName: "单据名称",
  tableName: undefined,
  fields: [],
};


let DefaultAppMenuDefinition = {
  id: undefined,
  appId: undefined,
  menuType: undefined,
  url: undefined,
  formMenuId: undefined,
  icon: undefined,
  actionTarget: 'current',
  fullScreen: '0',
  menuName: undefined,
  flowId: undefined,
  component: undefined,
  parentId: undefined
};

let DefaultFieldDefinition = {
  id: undefined,
  formId: undefined,
  showName: undefined,
  alias: undefined,
  inputType: undefined,
  component: undefined,
  originId: undefined,
  version: undefined,
  last: undefined,
  valueMin: undefined,
  valueMax: undefined,
  tableFieldName: undefined,
  updateTime: undefined,
  createTime: undefined,
  createBy: undefined
};

let DefaultMenuDefinition = {
  id: undefined,
  menuName: '列表名称',
  listPageUrl: undefined,
  listPageComponent: undefined,
  detailPageUrl: undefined,
  detailPageComponent: undefined,
  listFieldName: undefined,

  detailPcViewId: undefined,
  detailMobileViewId: undefined,

  formId: undefined,
  listField: undefined,
  orderBy: undefined,
  orderByType: undefined,
  flowId: undefined,
  remark: undefined,
  searchFields: undefined,
  menuActionRanges: [],
  menuButtons: []
};

let DefaultMenuButton = {
  formMenuId: undefined,
  appId: undefined,
  sort: undefined,
  buttonName: undefined,
  buttonActionType: undefined,
  pcViewId: undefined,
  pcViewActionId: undefined,
  mobileViewId: undefined,
  mobileViewActionId: undefined,
  supportMultiple: false,
  icon: undefined,
  processDefinitionId: undefined,
  forRow: false,
  buttonComponent: undefined,
  relations: [],

  pcViewKey: undefined,
  pcViewActionKey: undefined,
  mobileViewKey: undefined,
  mobileViewActionKey: undefined,
};

let DefaultButtonRelation = {
  sourceFormId: undefined,
  sourceFormName: undefined,

  sourceFormFieldId: undefined,
  sourceFormField: undefined,
  sourceFormFieldComponent: undefined,

  targetFormId: undefined,
  targetFormName: undefined,

  targetFormFieldId: undefined,
  targetFormField: undefined,
  targetFormFieldComponent: undefined,
  buttonId: undefined,
  sourceParentFormName: undefined,
  targetParentFormName: undefined,

  sourceMainField: undefined,
  targetMainField: undefined,
};


let DefaultMenuActionRange = {
  formMenuId: undefined,
  conditional: undefined,
  appId: undefined,
  preBracket: undefined,
  sufBracket: undefined,
  sort: undefined,
  joinType: undefined,
  fieldName: undefined,
  fieldValue: undefined,
  fieldValueTitle: undefined,
  fieldComponent: undefined,
  systemValue: false
};

let DefaultViewDefinition = {
  id: undefined,
  viewName: '视图名称',
  viewDefinition: '',
  viewDesignDefinition: '',
  main: '0',
  formId: undefined,
  width: 900,
  viewKey: undefined,
  viewActions: []
};

let DefaultFormula = {
  id: undefined,
  formulaText: undefined,
  formulaTitle: undefined,
  formulaRefs: null,
};

let DefaultFormUpdateAction = {
  mainFormId: undefined,
  fieldName: undefined, //发生更新的字段名
  formName: undefined,  //发生更新的单据名
  main: true,           //是否是主表单
  formBean: {},          //表单全内容
  viewActionId: undefined
};

let DefaultSystemFields = [{
  id: 'createBy', tableFieldName: 'create_by', component: 'TextInput', showName: '创建人'
}, {
  id: 'createTime', tableFieldName: 'create_time', component: 'TextInput', showName: '创建时间'
}, {
  id: 'updateTime', tableFieldName: 'update_time', component: 'TextInput', showName: '修改时间'
}, {
  id: 'flowStatus', tableFieldName: 'flow_status', component: 'FlowStatus', showName: '流程状态'
}];

let DefaultAppMenu = {
  id: undefined,
  menuType: undefined, //菜单类型(link 连接, formMenu 表单, tabs 标签, component 组件, folder 文件夹, flow 流程路由)
  url: undefined,
  formMenuId: undefined,
  actionTarget: undefined, //操作类型(current 在当前路由下打开, new 弹出框)
  fullScreen: 1,
  menuName: undefined,
  parentId: undefined,
  sort: undefined,
  component: undefined,
  path: undefined,
  flowId: undefined,
};

export {
  DefaultAppMenuDefinition,
  DefaultFormDefinition,
  DefaultViewDefinition,
  DefaultMenuDefinition,
  DefaultFieldDefinition,
  DefaultSubFormDefinition,
  DefaultViewAction,
  DefaultFieldAction,
  DefaultActionFormula,
  DefaultFormula,
  DefaultFormUpdateAction,
  DefaultSubFormButtonAction,
  DefaultSystemFields,
  DefaultMenuActionRange,
  DefaultMenuButton,
  DefaultButtonRelation,
  DefaultAppMenu
};
